﻿#region References

using System;
using System.Collections.Generic;
using DataAccessLayer.EntityDataModel;
using DataService.DataProviders;

#endregion

namespace DataService
{
    public class DataService : IDataService
    {
        #region IDataService Members

        /// <summary>
        /// Retreive data from local data cache.
        /// </summary>
        /// <returns>Collection of <see cref="Company"/> objects</returns>
        public List<Company> GetDataFromLocalStorage()
        {
           CompanyDataProvider dataProvider = new CompanyDataProvider(Configurator.LocalConnectionString);
           return dataProvider.GetAllCompanies();
        }

        /// <summary>
        /// Provides saving modified data into local data cache.
        /// </summary>
        /// <param name="dataList">Collection of <see cref="Company"/> objects</param>
        public void SubmitChangesToLocalStorage(List<Company> dataList)
        {
            CompanyDataProvider dataProvider = new CompanyDataProvider(Configurator.LocalConnectionString);
            dataProvider.UpdateCompanies(dataList);
        }

        /// <summary>
        /// Retreive data from remote server.
        /// </summary>
        /// <returns>Collection of <see cref="Company"/> objects</returns>
        public List<Company> GetDataFromRemoteStorage()
        {
            CompanyDataProvider dataProvider = new CompanyDataProvider(Configurator.RemoteConnectionString);
            return dataProvider.GetAllCompanies();
        }

        /// <summary>
        /// Provides saving modified data into remote database.
        /// </summary>
        /// <param name="dataList">Collection of <see cref="Company"/> objects</param>
        public void SubmitChangesToRemoteStorage(List<Company> dataList)
        {
            CompanyDataProvider dataProvider = new CompanyDataProvider(Configurator.RemoteConnectionString);
            dataProvider.UpdateCompanies(dataList);
        }

        /// <summary>
        /// Provides synchronization between local cache and remote data storage.
        /// </summary>
        public void Synchronize()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
